<?php
	//修改配置内容
	require '../biz/backend.php';

	class action extends backend
	{
		var $get_privilege_id = 93;
		var $post_privilege_id = 93;

		function do_get()
		{
			$config = load( 'biz.argument' );
			$result = $config->get( $this->input );

			$argument_type = load( 'biz.argument_type' );
			$type_data = $argument_type->all( $this->input );

			if ( ! empty( $result ) )
			{
				$template = load( 'template', array( 'domain'=>'tpl.admin' ) );
				$template->appoint( $result );

				$template->assign( 'type_data', $type_data['data'] );

				$template->assign( 'reference', isset( $this->input['reference'] ) ? urldecode( $this->input['reference'] ) : config( 'server.HTTP_REFERER' ) );
				echo $template->parse( 'set_argument.php' );
			}
		}

		function do_post()
		{
			$url = isset( $this->input['reference'] ) ? $this->input['reference'] : config( 'domain.admin' ) . 'list_argument.php';
			unset( $this->input['reference'] );

			$config = load( 'biz.argument' );
			$result = $config->set( $this->input );

			if ( $result['success'] )
			{
				$this->prompt( '成功修改配置参数', array( array( 'url' => config( 'domain.admin' ) . 'set_argument.php?id=' . $result['data']['id'] . '&reference=' . urlencode( $url ), 'name' => '继续修改' ), array( 'url' => $url, 'name' => '返回列表' ) ) );
			}
			else
			{
				$this->prompt( '修改失败', $this->transform( $result['message'], config( 'server.HTTP_REFERER' ) ) );
			}
		}
	}

	$action = new action();
	$action->run();
?>